<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>XX系统 - 房屋信息管理</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/lib/font-awesome/css/font-awesome.css">
</head>

<body>
<div class="box">
	<h3>房屋信息管理<a href="${pageContext.request.contextPath}/css/main.css"></a></h3>
	<div class="actions">
		<div>
			<a class="btn btn-primary" href="${pageContext.request.contextPath}/view/house/add.jsp">添加房屋信息</a>
			<input class="btn btn-primary"  type = "button" onclick = "fun()" value = "删除选中的"/>		
			</div>
		</div>
	
	
	
	<div class="actions">
		<div>
			<form action="${pageContext.request.contextPath}/HouseMFindServlet">
				地区：<input type = "text" name = "area">
				是否双气：<select name="isdouble">
							<option value="-1">请选择</option>
							<option value="0">是</option>
							<option value="1">否</option>
						</select>
				面积多少以上：<input type = "text" name = "acreage">
				出租状态：	<select name="status">
							<option value="-1" >请选择</option>
							<option value="1">未出租</option>
							<option value="2">已出租</option>
							<option value="3">停止出租</option>
						</select>
					<input type = "submit" value = "查询">
				</form>
		</div>
	</div>
  
	<table class="list">
		<tr>
			<th>选择</th>
			<th>房屋序号</th>
			<th>所属地区</th>
			<th>所属小区</th>
			<th>单元号</th>
			<th>所属楼层</th>
			<th>房间号</th>
			<th>面积</th>
			<th>装修</th>
			<th>朝向</th>
			<th>是否双气</th>
			<th>限主人数</th>
			<th>配套设施</th>
			<th>出租价格</th>
			<th>房屋状态</th>
			<th>房屋图片</th>
			<th>房屋地址</th>
			<th>添加时间</th>
			<th>修改时间</th>
			<th>房屋操作</th>
			
		</tr>
		<c:forEach  items="${pb.beanList }"  var="house">
		<tr>
			<td><input type = "checkbox" name = "name" value = "${house.h_id}"></td>
			<td>${house.h_id}</td>
			<td>${house.h_area}</td>
			<td>${house.h_estate}</td>
			<td>${house.h_unitNumber}</td>
			<td>${house.h_floor}</td>
			<td>${house.h_roomNo}</td>
			<td>${house.h_acreage}</td>
			<td>${house.h_direction}</td>
			<td>${house.h_fitment}</td>
			<td>${house.h_isDoubleAir}</td>
			<td>${house.h_limit}</td>
			<td>${house.h_facility}</td>
			<td>${house.h_price}</td>
			<td>${house.h_status}</td>
			<td>${house.h_img}</td>
			<td>${house.h_address}</td>
			<td>${house.h_addtime}</td>
			<td>${house.h_updateTime}</td>
			<td>
				<a class="fa fa-info" title="详情" href="detail.html"></a>
				&nbsp;&nbsp;
				<a class="fa fa-pencil" title="编辑" href="${pageContext.request.contextPath}/HousefindServlet?h_id=${house.h_id}"></a>
				&nbsp;&nbsp;
				<a class="fa fa-remove" title="删除" href="${pageContext.request.contextPath}/HouseDelServlet?h_id=${house.h_id}" onclick="confirmDelete(1)"></a>
			</td>
		</tr>
		</c:forEach>
	</table>
	<div class="pager-info">
		<div>共有 ${pb.tr } 条记录，第 ${pb.pc }/${pb.tp } 页 </div>
		<div>
			<ul class="pagination">
				<li class="paginate_button previous disabled }">
				<c:if test = "${pb.pc>1 }" >
				<a href="${pb.url }&pc=1">首页</a>
				</c:if>
				</li>
				<li class="paginate_button previous disabled }">
				<c:if test = "${pb.pc>1 }" >
				<a href="${pb.url }&pc=${pb.pc-1 }">上一页</a>
				</c:if>
				</li>
				<c:choose>
					<c:when test="${pb.pc<3 }">
						<c:set var = "begin" value = "1"></c:set>
						<c:set var = "end" value = "${pb.tp }"></c:set>
					</c:when>
					<c:otherwise>
						<c:set var = "begin" value = "${pb.pc-1 }"></c:set>
						<c:set var = "end" value = "${pb.pc+1 }"></c:set>
						<c:if test="${pb.pc-1<1 }">
						<c:set var = "begin" value = "1"></c:set>
						<c:set var = "end" value = "3"></c:set>
						</c:if>
						<c:if test="${pb.pc+1>pb.tp }">
						<c:set var = "begin" value = "${pb.tp-2 }"></c:set>
						<c:set var = "end" value = "${pb.tp }"></c:set>
						</c:if>	
					</c:otherwise>
					
				</c:choose>
				
				<c:forEach var = "i" begin = "${begin }" end = "${end }">
					<c:choose>
						<c:when test="${pb.pc == i }">
							<li class="paginate_button active"><a href = "#">${i }</a></li>
						</c:when>
						<c:otherwise>
							<li class="paginate_button next disabled"><a href="${pb.url }&pc=${i }">${i }</a></li>
						</c:otherwise>
					</c:choose>
				</c:forEach>
				
				<li class="paginate_button next disabled">
				<c:if test = "${pb.pc<pb.tp }" >
				<a href="${pb.url }&pc=${pb.pc+1 }">下一页</a>
				</c:if>
				</li>
				<li class="paginate_button next disabled">
				<c:if test = "${pb.pc<pb.tp }" >
				<a href="${pb.url }&pc=${pb.tp }">尾页</a>
				</c:if>
				</li>
			</ul>
		</div>
	</div>
</div>
<script src="${pageContext.request.contextPath}/lib/jquery/jquery.js"></script>
<script>
function confirmDelete(id){
	if (confirm("确定要删除码？")) {
		alert('发送删除请求，刷新页面（不要异步）');
	}
	return false;
}
</script>
	<script type="text/javascript">
		
		if(!(typeof(<%=request.getAttribute("msg") %>)=="object")){
			alert("${msg }")
		}
		function fun(){
			
			var name = document.getElementsByName("name");
			var list = [];
			
			for(var i = 0;i<name.length;i++){
				if(name[i].checked){
					list.push(name[i].value);
				}
			}
			window.location="HouseDelsServlet?list="+list;
		}
	
	</script>
</body>
</html>